local juesi = fk.CreateSkill {
  name = "mini__juesi",
}

Fk:loadTranslationTable{
  ["mini__juesi"] = "决死",
  [":mini__juesi"] = "出牌阶段，你可以弃置一张【杀】并选择一名其他角色，然后该角色弃置一张牌。若其弃置的牌不为【杀】，"..
  "你获得之，并视为对其使用一张【决斗】。",

  ["#mini__juesi"] = "决死：弃置一张【杀】，令一名角色弃一张牌",
  ["#mini__juesi-discard"] = "决死：你需弃置一张牌，若不为【杀】，%src获得之并视为对你使用【决斗】",

  ["$mini__juesi1"] = "不过一死而已，有何所惧。",
  ["$mini__juesi2"] = "自知今日必死，更当英勇杀敌。",
}

juesi:addEffect("active", {
  anim_type = "offensive",
  prompt = "#mini__juesi",
  card_num = 1,
  target_num = 1,
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).trueName == "slash" and not player:prohibitDiscard(to_select)
  end,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0 and to_select ~= player and not to_select:isNude()
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    room:throwCard(effect.cards, juesi.name, player, player)
    if target.dead then return end
    local id = room:askToDiscard(target, {
      min_num = 1,
      max_num = 1,
      include_equip = true,
      skill_name = juesi.name,
      prompt = "#mini__juesi-discard:"..player.id,
      cancelable = false,
      skip = true,
    })
    if #id > 0 then
      id = id[1]
      local card = Fk:getCardById(id)
      room:throwCard(card, juesi.name, target, target)
      if player.dead then return end
      if card.trueName ~= "slash" then
        if table.contains(room.discard_pile, id) then
          room:moveCardTo(id, Card.PlayerHand, player, fk.ReasonJustMove, juesi.name, nil, true, player)
        end
        if not player.dead and not target.dead then
          room:useVirtualCard("duel", nil, player, target, juesi.name)
        end
      end
    end
  end,
})

return juesi
